/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.sugree.twitter.views;

import com.sugree.twitter.TwitterController;
import java.util.Enumeration;
import java.util.Vector;
import javax.microedition.lcdui.Choice;
import javax.microedition.lcdui.Command;
import javax.microedition.lcdui.CommandListener;
import javax.microedition.lcdui.Displayable;

/**
 *
 * @author Luis fernando Muñoz Chacon
 */
public class FollowingScreen extends javax.microedition.lcdui.List implements CommandListener {
    private TwitterController controller;
    private Command cancelCommand;
    private Command followCommand;
    private Command unfollowCommand;

    private Vector users;

    public FollowingScreen(TwitterController controller) {
		super("Following", Choice.IMPLICIT);
		this.controller = controller;

                users = new Vector();

		followCommand = new Command("Follow", Command.ITEM, 1);
		addCommand(followCommand);

                unfollowCommand = new Command("unFollow", Command.ITEM, 1);
		addCommand(unfollowCommand);

		cancelCommand = new Command("Cancel", Command.CANCEL, 2);
		addCommand(cancelCommand);

		setCommandListener(this);
   }

    public void setUsers(Vector parUsers){
        this.users = parUsers;
        insertUsers();
    }

    private void insertUsers(){
        Enumeration userEnum;

        userEnum = users.elements();
        while(userEnum.hasMoreElements()){
            append((String)userEnum.nextElement(),null);
        }
    }

    public void commandAction(Command cmd, Displayable d) {
        int index = getSelectedIndex();
        if(cmd==cancelCommand){
            controller.showTimeline();
        }
    }


}
